package com.minimalist.common.entity.basic.vo.config;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.minimalist.common.config.swagger.SchemaEnum;
import com.minimalist.common.entity.basic.enums.StatusEnum;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author 11987
 */
@Schema(name = "参数配置实体")
public class ConfigVO implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    @NotNull(message = "参数ID不能为空", groups = {Update.class})
    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(name = "configId", description = "参数ID", type = "string")
    private Long configId;

    @NotBlank(message = "参数名称不能为空", groups = {Add.class, Update.class})
    @Schema(name = "configName", description = "参数名称", type = "string")
    private String configName;

    @NotBlank(message = "参数键名不能为空", groups = {Add.class, Update.class})
    @Schema(name = "configKey", description = "参数键名", type = "string")
    private String configKey;

    @NotBlank(message = "参数键值不能为空", groups = {Add.class, Update.class})
    @Schema(name = "configValue", description = "参数键值", type = "string")
    private String configValue;

    @Schema(name = "description", description = "说明", type = "string")
    private String description;

    @SchemaEnum(implementation = StatusEnum.class)
    @NotNull(message = "参数配置状态不能为空", groups = {Update.class})
    @Schema(name = "status", description = "参数配置状态", type = "integer")
    private Integer status;

    // Getter和Setter方法
    public Long getConfigId() {
        return configId;
    }

    public void setConfigId(Long configId) {
        this.configId = configId;
    }

    public String getConfigName() {
        return configName;
    }

    public void setConfigName(String configName) {
        this.configName = configName;
    }

    public String getConfigKey() {
        return configKey;
    }

    public void setConfigKey(String configKey) {
        this.configKey = configKey;
    }

    public String getConfigValue() {
        return configValue;
    }

    public void setConfigValue(String configValue) {
        this.configValue = configValue;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ConfigVO configVO = (ConfigVO) o;
        return Objects.equals(configId, configVO.configId) &&
                Objects.equals(configName, configVO.configName) &&
                Objects.equals(configKey, configVO.configKey) &&
                Objects.equals(configValue, configVO.configValue) &&
                Objects.equals(description, configVO.description) &&
                Objects.equals(status, configVO.status);
    }

    @Override
    public int hashCode() {
        return Objects.hash(configId, configName, configKey, configValue, description, status);
    }

    @Override
    public String toString() {
        return "ConfigVO{" +
                "configId=" + configId +
                ", configName='" + configName + '\'' +
                ", configKey='" + configKey + '\'' +
                ", configValue='" + configValue + '\'' +
                ", description='" + description + '\'' +
                ", status=" + status +
                '}';
    }
}
